import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class StudentGradeManager {
    // 使用Map存储学生成绩，key为学生ID，value为成绩
    private static Map<String, Integer> gradeMap = new HashMap<>();
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        while (true) {
            System.out.println("\n学生成绩管理系统");
            System.out.println("1. 记录学生成绩");
            System.out.println("2. 查询学生成绩");
            System.out.println("3. 退出");
            System.out.print("请选择操作: ");

            int choice = scanner.nextInt();
            scanner.nextLine(); // 消耗换行符

            switch (choice) {
                case 1:
                    recordGrade();
                    break;
                case 2:
                    queryGrade();
                    break;
                case 3:
                    System.out.println("退出系统...");
                    return;
                default:
                    System.out.println("无效选择，请重新输入！");
            }
        }
    }

    /**
     * 记录学生成绩
     */
    private static void recordGrade() {
        System.out.print("请输入学生ID: ");
        String studentId = scanner.nextLine();

        System.out.print("请输入学生成绩: ");
        int grade = scanner.nextInt();
        scanner.nextLine(); // 消耗换行符

        gradeMap.put(studentId, grade);
        System.out.println("成绩记录成功！");
    }

    /**
     * 查询学生成绩
     */
    private static void queryGrade() {
        System.out.print("请输入要查询的学生ID: ");
        String studentId = scanner.nextLine();

        Integer grade = gradeMap.get(studentId);
        if (grade != null) {
            System.out.println("学生 " + studentId + " 的成绩是: " + grade);
        } else {
            System.out.println("未找到该学生的成绩记录！");
        }
    }
}